#ifndef __ejpeg_H_
#define __ejpeg_H_

#include "stdint.h"

typedef struct JPEG_ENCODER_STRUCTURE1
{
	 uint16_t mcu_width;
	 uint16_t mcu_height;
	 uint16_t horizontal_mcus;
	 uint16_t vertical_mcus;
	 uint16_t rows_in_bottom_mcus;
	 uint16_t cols_in_right_mcus;
	 uint16_t length_minus_mcu_width;
	 uint16_t length_minus_width;
	 uint16_t mcu_width_size;
	 uint16_t offset;
	 int16_t ldc1;
	 int16_t ldc2;
	 int16_t ldc3;
	 uint16_t rows;
	 uint16_t cols;
	 uint16_t incr;
}JPEG_ENCODER_STRUCTURE;


static void RGB_2_400(uint8_t *input_ptr, uint8_t *output_ptr, uint32_t image_width,uint32_t image_height); 
static void read_400_format(JPEG_ENCODER_STRUCTURE *jpeg_encoder_structure,uint8_t *input_ptr); 
static void RGB_2_422(uint8_t *input_ptr, uint8_t *output_ptr, uint32_t image_width, uint32_t image_height); 
uint16_t DSP_Division (uint32_t numer, uint32_t denom);
uint8_t * write_markers (uint8_t * output_ptr, uint32_t image_format,uint32_t image_width, uint32_t image_height);
static void read_422_format (JPEG_ENCODER_STRUCTURE *jpeg_encoder_structure,uint8_t *input_ptr);
static void initialization (JPEG_ENCODER_STRUCTURE *jpeg, uint32_t image_format,uint32_t image_width, uint32_t image_height); 
void initialize_quantization_tables (uint32_t quality_factor); 
uint8_t *close_bitstream (uint8_t *output_ptr); 
static void DCT (int16_t *data); 
void quantization (int16_t *const data, uint16_t *const quant_table_ptr); 
uint8_t * huffman (JPEG_ENCODER_STRUCTURE * jpeg_encoder_structure,uint16_t component, uint8_t *output_ptr); 
static uint8_t *encodeMCU (JPEG_ENCODER_STRUCTURE *jpeg_encoder_structure,uint32_t image_format, uint8_t *output_ptr);
uint32_t encode_image (uint8_t *input_ptr, uint8_t *output_ptr,uint32_t quality_factor, uint32_t image_format,uint32_t image_width, uint32_t image_height); 






#endif
